ABSTRACT
Programs are rarely implemented in a single language, and thus questions of type soundness should address not only the semantics of a single language, but how it interacts with others. Even between type-safe languages, disparate features can frustrate interoperability, as invariants from one language can easily be violated in the other. In their seminal 2007 paper, Matthews and Findler proposed a multi-language construction that augments the interoperating languages with a pair of boundaries that allow code from one language to be embedded in the other. While this technique has been widely applied, their syntactic source-level interoperability doesn’t reflect practical implementations, where the behavior of interaction is only defined after compilation to a common target, and any safety must be ensured by target invariants or inserted target-level “glue code.”
In this paper, we present a novel framework for the design and verification of sound language interoperability that follows an interoperation-after-compilation strategy. Language designers specify what data can be converted between types of the two languages via a convertibility relation τA ∼ τB (“τA is convertible to τB”) and specify target-level glue code implementing the conversions. Then, by giving a semantic model of source-language types as sets of target-language terms, they can establish not only the meaning of the source types, but also soundness of conversions: i.e., whenever τA ∼ τB, the corresponding pair of conversions (glue code) convert target terms that behave like τA to target terms that behave like τB, and vice versa. With this, they can prove semantic type soundness for the entire system. We illustrate our framework via a series of case studies that demonstrate how our semantic interoperation-after-compilation approach allows us both to account for complex differences in language semantics and make efficiency trade-offs based on particularities of compilers or targets.
- Amal Ahmed, Andrew W. Appel, Christopher D. Richards, Kedar N. Swadi, Gang Tan, and Daniel C. Wang. 2010. Semantic Foundations for Typed Assembly Languages. ACM Transactions on Programming Languages and Systems, 32, 3 (2010), March, 1–67.Google ScholarDigital Library
- Amal Ahmed and Matthias Blume. 2011. An equivalence-preserving CPS translation via multi-language semantics. In Proceeding of the 16th ACM SIGPLAN international conference on Functional Programming, ICFP 2011, Tokyo, Japan, September 19-21, 2011, Manuel M. T. Chakravarty, Zhenjiang Hu, and Olivier Danvy (Eds.). ACM, 431–444. https://doi.org/10.1145/2034773.2034830 Google ScholarDigital Library
- Amal Ahmed, Matthew Fluet, and Greg Morrisett. 2007. L3 : A Linear Language with Locations. Fundamenta Informaticae, 77, 4 (2007), June, 397–449.Google ScholarDigital Library
- Amal Jamil Ahmed. 2004. Semantics of Types for Mutable State. Ph.D. Dissertation. Princeton University.Google ScholarDigital Library
- Andrew W. Appel and David A. McAllester. 2001. An indexed model of recursive types for foundational proof-carrying code. ACM Trans. Program. Lang. Syst., 23, 5 (2001), 657–683. https://doi.org/10.1145/504709.504712 Google ScholarDigital Library
- Edd Barrett, Carl Friedrich Bolz, Lukas Diekmann, and Laurence Tratt. 2016. Fine-grained Language Composition: A Case Study. In 30th European Conference on Object-Oriented Programming (ECOOP 2016), Shriram Krishnamurthi and Benjamin S. Lerner (Eds.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 56). Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany. 3:1–3:27. isbn:978-3-95977-014-9 issn:1868-8969 https://doi.org/10.4230/LIPIcs.ECOOP.2016.3 Google ScholarCross Ref
- David M. Beazley. 1996. SWIG: An Easy to Use Tool for Integrating Scripting Languages with C and C++. In Fourth Annual USENIX Tcl/Tk Workshop 1996, Monterey, California, USA, July 10-13, 1996, Mark Diekhans and Mark Roseman (Eds.). USENIX Association. https://www.usenix.org/legacy/publications/library/proceedings/tcl96/beazley.htmlGoogle Scholar
- Nick Benton. 2006. Abstracting allocation: The new new thing. In Computer Science Logic (CSL).Google Scholar
- Nick Benton and Chung-Kil Hur. 2009. Biorthogonality, Step-indexing and Compiler Correctness. In Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming (ICFP ’09). ACM, New York, NY, USA. 97–108. isbn:978-1-60558-332-7 https://doi.org/10.1145/1596550.1596567 Google ScholarDigital Library
- Nick Benton, Andrew Kennedy, and Claudio V Russo. 2004. Adventures in interoperability: the sml. net experience. In Proceedings of the 6th ACM SIGPLAN International conference on Principles and Practice of Declarative Programming. 215–226.Google ScholarDigital Library
- Nick Benton and Nicolas Tabareau. 2009. Compiling functional types to relational specifications for low level imperative code. In Proceedings of TLDI’09: 2009 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, Savannah, GA, USA, January 24, 2009. 3–14.Google ScholarDigital Library
- Nick Benton and Uri Zarfaty. 2007. Formalizing and Verifying Semantic Type Soundness of a Simple Compiler. In Proceedings of the 9th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP ’07). Association for Computing Machinery, New York, NY, USA. 1–12. isbn:9781595937698 https://doi.org/10.1145/1273920.1273922 Google ScholarDigital Library
- Matthias Blume. 2001. No-longer-foreign: Teaching an ML compiler to speak C “natively”. Electronic Notes in Theoretical Computer Science, 59, 1 (2001), 36–52.Google ScholarCross Ref
- Samuele Buro, Roy Crole, and Isabella Mastroeni. 2020. Equational logic and categorical semantics for multi-languages. Electronic Notes in Theoretical Computer Science, 352 (2020), 79–103.Google ScholarCross Ref
- Samuele Buro and Isabella Mastroeni. 2019. On the Multi-Language Construction.. In ESOP. 293–321.Google Scholar
- Manuel MT Chakravarty. 1999. C->HASKELL, or Yet Another Interfacing Tool. In Symposium on Implementation and Application of Functional Languages. 131–148.Google Scholar
- Christos Dimoulas, Sam Tobin-Hochstadt, and Matthias Felleisen. 2012. Complete Monitors for Behavioral Contracts. In European Symposium on Programming (ESOP).Google Scholar
- Robert Bruce Findler and Matthias Blume. 2006. Contracts as pairs of projections. In International Symposium on Functional and Logic Programming. 226–241.Google ScholarDigital Library
- Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for higher-order functions. In Proceedings of the seventh ACM SIGPLAN international conference on Functional programming. 48–59.Google ScholarDigital Library
- Kathryn E Gray. 2008. Safe cross-language inheritance. In European Conference on Object-Oriented Programming. 52–75.Google ScholarDigital Library
- Kathryn E Gray, Robert Bruce Findler, and Matthew Flatt. 2005. Fine-grained interoperability through mirrors and contracts. ACM SIGPLAN Notices, 40, 10 (2005), 231–245.Google ScholarDigital Library
- Matthias Grimmer, Chris Seaton, Roland Schatz, Thomas Würthinger, and Hanspeter Mössenböck. 2015. High-performance cross-language interoperability in a multi-language runtime. In Proceedings of the 11th Symposium on Dynamic Languages. 78–90.Google ScholarDigital Library
- Rich Hickey. 2020. A history of Clojure. Proceedings of the ACM on programming languages, 4, HOPL (2020), 1–46.Google ScholarDigital Library
- Kohei Honda. 1993. Types for dyadic interaction. In International Conference on Concurrency Theory. 509–523.Google ScholarCross Ref
- Kohei Honda, Vasco T Vasconcelos, and Makoto Kubo. 1998. Language primitives and type discipline for structured communication-based programming. In European Symposium on Programming. 122–138.Google ScholarCross Ref
- Jonas B. Jensen, Nick Benton, and Andrew Kennedy. 2013. High-Level Separation Logic for Low-Level Code. POPL ’13. Association for Computing Machinery, New York, NY, USA. 301–314. isbn:9781450318327 https://doi.org/10.1145/2429069.2429105 Google ScholarDigital Library
- Ralf Jung, Jacques-Henri Jourdan, Robbert Krebbers, and Derek Dreyer. 2018. RustBelt: Securing the Foundations of the Rust Programming Language. In ACM Symposium on Principles of Programming Languages (POPL).Google Scholar
- Andrew Kennedy and Don Syme. 2001. Design and Implementation of Generics for the .NET Common Language Runtime. In Proceedings of the ACM SIGPLAN 2001 Conference on Programming Language Design and Implementation (PLDI ’01). Association for Computing Machinery, New York, NY, USA. 1–12. isbn:1581134142 https://doi.org/10.1145/378795.378797 Google ScholarDigital Library
- Robert Kleffner. 2017. A Foundation for Typed Concatenative Languages. Master’s thesis. Northeastern University.Google Scholar
- Neelakantan R. Krishnaswami, Pierre Pradic, and Nick Benton. 2015. Integrating Linear and Dependent Types. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, Mumbai, India, January 15-17, 2015, Sriram K. Rajamani and David Walker (Eds.). ACM, 17–30. https://doi.org/10.1145/2676726.2676969 Google ScholarDigital Library
- Paul Blain Levy. 2001. Call-by-Push-Value. Queen Mary, University of London. London, UK.Google Scholar
- Phillip Mates, Jamie Perconti, and Amal Ahmed. 2019. Under Control: Compositionally Correct Closure Conversion with Mutable State. In ACM Conference on Principles and Practice of Declarative Programming (PPDP).Google Scholar
- Jacob Matthews and Robert Bruce Findler. 2007. Operational semantics for multi-language programs. In Proceedings of the 34th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2007, Nice, France, January 17-19, 2007, Martin Hofmann and Matthias Felleisen (Eds.). ACM, 3–10. https://doi.org/10.1145/1190216.1190220 Google ScholarDigital Library
- Robin Milner. 1978. A theory of type polymorphism in programming. J. Comput. Syst. Sci., 17 (1978), 348–375.Google ScholarCross Ref
- Robin Milner, Joachim Parrow, and David Walker. 1992. A calculus of mobile processes, i. Information and computation, 100, 1 (1992), 1–40.Google Scholar
- Max S. New and Amal Ahmed. 2018. Graduality from Embedding-Projection Pairs. In ICFP. Proceedings of the ACM on Programming Languages, 2, 73:1–73:30.Google ScholarDigital Library
- Max S. New, William J. Bowman, and Amal Ahmed. 2016. Fully abstract compilation via universal embedding. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming, ICFP 2016, Nara, Japan, September 18-22, 2016, Jacques Garrigue, Gabriele Keller, and Eijiro Sumii (Eds.). ACM, 103–116. https://doi.org/10.1145/2951913.2951941 Google ScholarDigital Library
- Max S. New, Dustin Jamner, and Amal Ahmed. 2020. Graduality and Parametricity: Together Again for the First Time. Proceedings of the ACM on Programming Languages, 4, POPL, 46:1–46:32.Google Scholar
- Max S New, Daniel R Licata, and Amal Ahmed. 2019. Gradual type theory. Proceedings of the ACM on Programming Languages, 3, POPL (2019), 15:1–15:31.Google ScholarDigital Library
- Martin Odersky and Matthias Zenger. 2005. Scalable component abstractions. In Proceedings of the 20th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications. 41–57.Google ScholarDigital Library
- Peter-Michael Osera, Vilhelm Sjöberg, and Steve Zdancewic. 2012. Dependent interoperability. In Proceedings of the sixth workshop on Programming Languages meets Program Verification, PLPV 2012, Philadelphia, PA, USA, January 24, 2012, Koen Claessen and Nikhil Swamy (Eds.). ACM, 3–14. https://doi.org/10.1145/2103776.2103779 Google ScholarDigital Library
- Daniel Patterson, Noble Mushtak, Andrew Wagner, and Amal Ahmed. 2022. Semantic Soundness for Language Interoperability (Technical Appendix). March, Available at https://dbp.io/pubs/2022/semint-tr.pdf.Google Scholar
- Daniel Patterson, Jamie Perconti, Christos Dimoulas, and Amal Ahmed. 2017. FunTAL: reasonably mixing a functional language with assembly. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2017, Barcelona, Spain, June 18-23, 2017, Albert Cohen and Martin T. Vechev (Eds.). ACM, 495–509. https://doi.org/10.1145/3062341.3062347 Google ScholarDigital Library
- James T. Perconti and Amal Ahmed. 2014. Verifying an Open Compiler Using Multi-language Semantics. In Programming Languages and Systems - 23rd European Symposium on Programming, ESOP 2014, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2014, Grenoble, France, April 5-13, 2014, Proceedings, Zhong Shao (Ed.) (Lecture Notes in Computer Science, Vol. 8410). Springer, 128–148. https://doi.org/10.1007/978-3-642-54833-8_8 Google ScholarDigital Library
- Gabriel Scherer, Max S. New, Nick Rioux, and Amal Ahmed. 2018. FabULous Interoperability for ML and a Linear Language. In Foundations of Software Science and Computation Structures - 21st International Conference, FOSSACS 2018, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2018, Thessaloniki, Greece, April 14-20, 2018, Proceedings, Christel Baier and Ugo Dal Lago (Eds.) (Lecture Notes in Computer Science, Vol. 10803). Springer, 146–162. https://doi.org/10.1007/978-3-319-89366-2_8 Google ScholarCross Ref
- Zhong Shao and Valery Trifonov. 1998. Type-directed continuation allocation. In International Workshop on Types in Compilation. 116–135.Google ScholarCross Ref
- T. Stephen Strickland, Sam Tobin-Hochstadt, Robert Bruce Findler, and Matthew Flatt. 2012. Chaperones and Impersonators: Run-Time Support for Reasonable Interposition. In ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA). Association for Computing Machinery, New York, NY, USA. 943–962. isbn:9781450315616 https://doi.org/10.1145/2384616.2384685 Google ScholarDigital Library
- Don Syme. 2006. Leveraging. NET meta-programming components from F# integrated queries and interoperable heterogeneous execution. In Proceedings of the 2006 workshop on ML. 43–54.Google ScholarDigital Library
- Kaku Takeuchi, Kohei Honda, and Makoto Kubo. 1994. An interaction-based language and its typing system. In International Conference on Parallel Architectures and Languages Europe. 398–413.Google ScholarCross Ref
- Jesse Tov and Riccardo Pucella. 2010. Stateful Contracts for Affine Types. In Programming Languages and Systems, 19th European Symposium on Programming, ESOP 2010, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2010, Paphos, Cyprus, March 20-28, 2010. Proceedings.Google Scholar
- Valery Trifonov and Zhong Shao. 1999. Safe and principled language interoperation. In European Symposium on Programming. 128–146.Google Scholar
- Alexi Turcotte, Ellen Arteca, and Gregor Richards. 2019. Reasoning About Foreign Function Interfaces Without Modelling the Foreign Language. In 33rd European Conference on Object-Oriented Programming (ECOOP 2019), Alastair F. Donaldson (Ed.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 134). Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany. 16:1–16:32. isbn:978-3-95977-111-5 issn:1868-8969 https://doi.org/10.4230/LIPIcs.ECOOP.2019.16 Google ScholarCross Ref
- Peng Wang, Santiago Cuellar, and Adam Chlipala. 2014. Compiler Verification Meets Cross-Language Linking via Data Abstraction. In Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA ’14). Association for Computing Machinery, New York, NY, USA. 675–690. isbn:9781450325851 https://doi.org/10.1145/2660193.2660201 Google ScholarDigital Library
- Jeremy Yallop, David Sheets, and Anil Madhavapeddy. 2018. A modular foreign function interface. Science of Computer Programming, 164 (2018), 82–97.Google ScholarCross Ref
- Jyun-Yan You. 2021. Rust Bindgen. https://github.com/rust-lang/rust-bindgenGoogle Scholar
Index Terms
- Semantic soundness for language interoperability
Recommendations
Semantic Encapsulation using Linking Types
TyDe 2023: Proceedings of the 8th ACM SIGPLAN International Workshop on Type-Driven DevelopmentInteroperability pervades nearly all mainstream language implementations, as most systems leverage subcomponents written in different languages. And yet, such linking can expose a language to foreign behaviors that are internally inexpressible, which ...
Modular and automated type-soundness verification for language extensions
ICFP '13: Proceedings of the 18th ACM SIGPLAN international conference on Functional programmingLanguage extensions introduce high-level programming constructs that protect programmers from low-level details and repetitive tasks. For such an abstraction barrier to be sustainable, it is important that no errors are reported in terms of generated ...
Lightweight soundness for towers of language extensions
PEPM 2017: Proceedings of the 2017 ACM SIGPLAN Workshop on Partial Evaluation and Program ManipulationIt is quite natural to define a software language as an extension of a base language. A compiler builder usually prefers to work on a representation in the base language, while programmers prefer to program in the extended language. As we define a ...
Comments